package com.chenyun.cocobackend.controller;

import com.chenyun.cocobackend.entity.User;
import com.chenyun.cocobackend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public boolean saveUser(User user) {
        return userService.add(user);
    }

    @PostMapping("/delete")
    public boolean delete(Integer id) {
        return userService.delete(id);
    }
    @GetMapping("/select")
    public List<User> getUsers(User user) {
        return userService.select();
    }

    @PostMapping("/update")
    public boolean update(User user) {
        return userService.update(user);
    }

}
